home *** CD-ROM | disk | FTP | other *** search
- ****************
- ** Listing 1 **
- ****************
-
- /*
-
- timer_int() -- Timer interrupt routine
-
- This routine handle the incoming timer interrupt. The
- interrupt is acknowledged and cleared. Then the alarm()
- routine is forked to handle the rest of the timer stuff.
-
- */
-
- void timer_int()
- {
- while (1)
- {
- /* Clear timer interrupt here. */
- outp(0x20, 0x20);
-
- /* Fork the processing routine. */
- fork_driver(alarm);
- }
- }
-
-
-
-
- /*
-
- alarm() -- Timer Alarm routine
-
- This routine is the fork routine of the system timer
- device.
-
- It will alert any tasks that have expiring system
- timers this tick.
-
- */
-
- void alarm(dummy, tcb)
- unsigned long dummy;
- TSS *tcb;
- {
-
- /* Time slice -- Significant event */
-
- significant_event = 1;
-
- /* One more tick... */
-
- ++timer_interrupts;
-
- /* For each item on the queue (which is in least to
- most time to wait order), see if the top of the
- queue is ready to alert.
-
- Alerting consists of setting the target task's event
- flags and delivering any required Asynchronous
- Traps (ASTs). */
-
- while (timer_waiting)
- {
- /* Change to proper LDT of next task. */
- set_ldt(timer_waiting_ldt, tcb);
-
- /* Check to see if timer has expired for this task. */
- if ((long) (timer_interrupts -
- ((P_TIMER *) timer_waiting -> pblock) ->
- wakeup) >= 0)
- {
- /* Timer has expired. Set appropriate event. */
- set_event(timer_waiting -> my_handle.t,
- timer_waiting -> ef_cluster,
- timer_waiting -> ef_mask);
-
- /* Deliver AST as required. */
- deliver_ast(timer_waiting -> my_handle.t,
- timer_waiting -> ast_addr);
-
- /* Remove from timer list and continue. */
- timer_waiting_ldt = timer_waiting -> link_ldt;
- timer_waiting = timer_waiting -> link;
- }
- else
- /* Timer hasn't expired. Don't check any more
- since the tasks are sorted in ascending order. */
- break;
- }
- }